﻿@page "/Pies/Gauge3"
@using LiveChartsCore
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.SkiaSharpView.Extensions
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore.Defaults
@using LiveChartsCore.Measure

<style>
	.sample-wrap {
		display: inline-block;
		width: 600px;
		height: 600px;
	}
</style>

<div class="sample-wrap">
	<PieChart
		Series="Series"
		InitialRotation="45"
        MaxAngle="270"
        MinValue="0"
        MaxValue="100">
	</PieChart>
</div>

@code {
    private ISeries[] Series { get; set; }

    protected override void OnInitialized()
    {
        Series = GaugeGenerator.BuildSolidGauge(
            new GaugeItem(30, series => SetStyle("Vanessa", series)),
            new GaugeItem(50, series => SetStyle("Charles", series)),
            new GaugeItem(70, series => SetStyle("Ana", series)),
            new GaugeItem(GaugeItem.Background, series =>
            {
                series.InnerRadius = 20;
            }));
    }

    public static void SetStyle(string name, PieSeries<ObservableValue> series)
    {
        series.Name = name;
        series.DataLabelsPosition = PolarLabelsPosition.Start;
        series.DataLabelsFormatter =
                point => $"{point.Coordinate.PrimaryValue} {point.Context.Series.Name}";
        series.InnerRadius = 20;
        series.RelativeOuterRadius = 8;
        series.RelativeInnerRadius = 8;
    }
}
